package org.beetl.json;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Test {

	public static void main(String[] args)throws IOException {
		{
			JsonTool.addLocationAction("~d:f'yyyy.MM.dd'");			
			Policy policy = JsonTool.getDefaultPolicy(User.class);				
			User user = new User();		
			String jsonString = policy.toJson(user);
			String ojbString = user.toString();
			System.out.println("ojbString="+ojbString);
			System.out.println("jsonString="+jsonString);
		}
	}	

}
//忽略属性name，对于double类型输出统一采用保留小数点2位
@Json(policy="name:k'userName',~f:f'#.##'")
class User{
	String name="joel";
	int age =12;
	double salary=12.32266;
	List<Customer>  list = new ArrayList<Customer>();
	public User(){
		Customer c = new Customer();
		list.add(c);
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public double getSalary() {
		return salary;
	}
	public void setSalary(double salary) {
		this.salary = salary;
	}
	public List<Customer> getList() {
		return list;
	}
	public void setList(List<Customer> list) {
		this.list = list;
	}
	@Override
	public String toString() {
		return "User [name=" + name + ", age=" + age + ", salary=" + salary
				+ ", list=" + list + "]";
	}
	
}
@Json(policy="name:k'userName'")
class Customer{
	String name="lijz";
	int age=11;
	Date bir = new Date();
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public Date getBir() {
		return bir;
	}
	public void setBir(Date bir) {
		this.bir = bir;
	}
	@Override
	public String toString() {
		return "Customer [name=" + name + ", age=" + age + ", bir=" + bir + "]";
	}
	
	
	
	
}
